
#include "iconfont.h"
#include <QFontDatabase>
#include <QMutex>



IconFont *IconFont::IconFontInstance()
{
    static QMutex mutex;
    static QScopedPointer<IconFont> inst;

    if (Q_UNLIKELY(!inst)) {
        mutex.lock();
        if (!inst) {
            inst.reset(new IconFont);
        }
        mutex.unlock();
    }
    return inst.data();
}

IconFont::IconFont()
{
    QFontDatabase fontDb;
    if (!fontDb.families().contains("iconfont")) {
        int fontId = fontDb.addApplicationFont(":/icon/iconfont.ttf");
        QStringList fontName = fontDb.applicationFontFamilies(fontId);
        if (fontName.count() == 0) {
//            qDebug() << "load iconfont.ttf error";
        }
    }
    if (fontDb.families().contains("iconfont")) {
        iconFont = QFont("iconfont");
        iconFont.setHintingPreference(QFont::PreferNoHinting);
    }
}

IconFont::~IconFont()
{

}
